package ac.github.os.internal.core.condition.impl.economy

import ac.github.os.internal.core.condition.Condition
import ac.github.os.internal.core.condition.call
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.core.trigger.PlayerTrigger
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake
import taboolib.platform.compat.VaultService

@Awake
class EconomyCondition : Condition {
    override fun doScreen(session: Session, config: StringConfig): Boolean {
        return session.call<PlayerTrigger> {
            val economy = VaultService.economy ?: throw NullPointerException("未检测到Vault或Impl")
            economy.has(it.player, config.get("val", 0.0)!!)
        }
    }

    override val namespace: String
        get() = "econ"
}